//package com.specialized.orders.service.impl;
//
//import com.alibaba.fastjson.JSONObject;
//import lombok.extern.log4j.Log4j2;
//import org.apache.commons.collections4.CollectionUtils;
//import org.apache.shardingsphere.api.sharding.complex.ComplexKeysShardingAlgorithm;
//import org.apache.shardingsphere.api.sharding.complex.ComplexKeysShardingValue;
//
//import java.util.ArrayList;
//import java.util.Collection;
//import java.util.List;
//
//@Log4j2
//public class IComplexKeysShardingAlgonithm implements ComplexKeysShardingAlgorithm {
//
//
//    @Override
//    public Collection<String> doSharding(Collection collection, ComplexKeysShardingValue shardingValue) {
//        log.info("collection->" + JSONObject.toJSONString(collection));
//        log.info("shardingValue->" + JSONObject.toJSONString(shardingValue));
//        List<Long> orderCardList = (List<Long>) shardingValue.getColumnNameAndShardingValuesMap().get("orderCard");
//        List<Long> userIdList = (List<Long>) shardingValue.getColumnNameAndShardingValuesMap().get("userId");
//        log.info(userIdList.toString());
//        List<String> list = new ArrayList();
//        if(!CollectionUtils.isEmpty(userIdList)){
//            Long userId = userIdList.get(0);
//            Long mode = userId % collection.size();
//            list.add("real_time"+mode);
//            return list;
//        }
//        if(!CollectionUtils.isEmpty(orderCardList)){
//            String orderCard = String.valueOf(orderCardList.get(0));
//            String string = String.valueOf(orderCard);
//            String substring = string.substring(10);
//            Long value = Long.valueOf(substring) % collection.size();
//            list.add("real_time" + value);
//            return list;
//        }
//        return list;
//    }
//
//
//
//
//}
